from django.shortcuts import render

from board_app.models import Topic

# Create your views here.

def index(request):# 主页
    return render(request,'board_app/index.html')


def topics(request):
    topicsList = Topic.objects.order_by('addedTime')
    context={'topics':topicsList}
    return render(request,'board_app/topics.html',context)

def topic_page(request,topic_id):
    topic = Topic.objects.get(id=topic_id)
    posts=topic.post_set.order_by( 'addedTime' )
    context={'topic':topic,'posts':posts}
    return render(request,'board_app/topic_page.html',context)


def new_topic(request):
    return render(request,'board_app/new_topic.html')


def new_post(request):
    return render(request,'board_app/new_post.html')